﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 学生选课及成绩查询管理系统
{
    public partial class RootLogin : Form
    {
        public RootLogin()
        {
            InitializeComponent();
        }


        User user;

        internal User User
        {
            get { return user; }
            set { user = value; }
        }

        internal void Welcome(User user)
        {
            toolStripStatusLabel1.Text = "欢迎用户:" + user.Userid + "_" + user.Username;
        }

        private void 成绩ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 学生管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 学生录入ToolStripMenuItem_Click(object sender, EventArgs e)
        {  

            
            if (this.MdiChildren.Count() < 1)
            {
                addStudentInfo asi = new addStudentInfo();
                asi.MdiParent = this;
                asi.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 统计信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void RootLogin_Load(object sender, EventArgs e)
        {
            toolStripStatusLabel3.Text = DateTime.Now.ToString();
        }

        private void toolStripStatusLabel3_Click(object sender, EventArgs e)
        {
            toolStripStatusLabel3.Text = DateTime.Now.ToString();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            toolStripStatusLabel3.Text = DateTime.Now.ToString();
        }

        private void RootLogin_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("是否要退出程序", "关闭提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                e.Cancel = true;
            }
            else
            {
                Dispose();
                Application.Exit();
            }
        }

        private void 修改个人密码ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                UpdatePwd up = new UpdatePwd();
                up.User = user;
                up.MdiParent = this;
                up.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 查看学生信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                //查改删都在这张表
                findAllorOneStudentInfo faos = new findAllorOneStudentInfo();
                faos.MdiParent = this;
                faos.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 删除学生信息ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                findAllorOneStudentInfo faos = new findAllorOneStudentInfo();
                faos.MdiParent = this;
                faos.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 修改学生信息ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                findAllorOneStudentInfo faos = new findAllorOneStudentInfo();
                faos.MdiParent = this;
                faos.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 课程录入ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                addCourseInfo aci = new addCourseInfo();
                aci.MdiParent = this;
                aci.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 查看课程信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                findAllorOneCourseInfo faci = new findAllorOneCourseInfo();
                faci.MdiParent = this;
                faci.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 修改课程ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                findAllorOneCourseInfo faci = new findAllorOneCourseInfo();
                faci.MdiParent = this;
                faci.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        //教师录入信息
        private void 学期统计ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                addTeacherInfo ati = new addTeacherInfo();
                ati.MdiParent = this;
                ati.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 查看老师信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                findAllorOneTeacherInfo fati = new findAllorOneTeacherInfo();
                fati.MdiParent = this;
                fati.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 删除老师ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                findAllorOneTeacherInfo fati = new findAllorOneTeacherInfo();
                fati.MdiParent = this;
                fati.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 修改老师ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                findAllorOneTeacherInfo fati = new findAllorOneTeacherInfo();
                fati.MdiParent = this;
                fati.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 班级录入ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                addClassInfo aci = new addClassInfo();
                aci.MdiParent = this;
                aci.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 查看班级ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                fiindAllorOneClassInfo faci = new fiindAllorOneClassInfo();
                faci.MdiParent = this;
                faci.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 删除班级ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                fiindAllorOneClassInfo faci = new fiindAllorOneClassInfo();
                faci.MdiParent = this;
                faci.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 修改班级ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.MdiChildren.Count() < 1)
            {
                fiindAllorOneClassInfo faci = new fiindAllorOneClassInfo();
                faci.MdiParent = this;
                faci.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 各班班级人数ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //DataGridView dgv1 = new DataGridView();
            //string sql = "select classname, count(classno) as '人数' from class join student on student.classno=class.classno";
            //DataTable dt =DBAccess.GetTable(sql);
            //dgv1.DataSource = dt;
            if (this.MdiChildren.Count() < 1)
            {
                ShowStudentCountforClass sscfc = new ShowStudentCountforClass();
                sscfc.MdiParent = this;
                sscfc.Show();
            }
            else
            {
                MessageBox.Show("只能打开一个Mdi子窗体");
            }
        }

        private void 注销ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("注销成功!");
            Form1 f1 = new Form1(user);
            f1.Show();
            this.Hide();
        }
    }
}
